package com.wwm.findit;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by wangzw on 15/5/28.
 */
public class Item
{
	public String itemname;
	public String username;
	public int level;
	public int amount;
	public int value;

	public String tip1;
	public String tip2;
	public String tip3;
	public String msg;

	public String latitude;
	public String longtitude;

	public String md5;

	/*
	*
	*  $md5= $obj->{'md5'};
    $username = $obj->{'username'};
    $level = (int)$obj->{'level'};
    $tip_one = $obj->{'tip_one'};
    $tip_two= $obj->{'tip_two'};
    $tip_three= $obj->{'tip_three'};
    $msg = $obj->{'msg'};
    $value = (double)($obj->{'value'});
    $num = (int)($obj->{'number'});
    */

	public Item(JSONObject json)
	{
		try
		{
			this.md5 = json.getString("md5");
			this.username = json.getString("username");
			this.level = json.getInt("level");
			this.amount = json.getInt("num");
			this.value = json.getInt("value");
			this.tip1 = json.getString("tip_one");
			this.tip2 = json.getString("tip_two");
			this.tip3 = json.getString("tip_three");
			this.msg = json.getString("msg");
			this.itemname = json.getString("objectname");

			if (null != json.getString("dimension") && null != json.getString("longitude"))
			{
				this.latitude = json.getString("dimension");
				this.longtitude = json.getString("longitude");
			}

		} catch (JSONException e)
		{
			e.printStackTrace();
		}

	}

	public Item(String name, String md5, int level, int value)
	{
		this.itemname = name;
		this.md5 = md5;
		this.level = level;
		this.value = value;
	}
}
